package com.wangshili.common.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class SysExceptionAspect {
	private static final Logger log = 
			LoggerFactory.getLogger(AspectTest.class);
	
//	@Pointcut("bean(*ServiceImpl)")
	//说明：AfterThrowing中throwing属性的值，需要与它描述的方法的异常参数名相同。
	@AfterThrowing(pointcut="bean(*ServiceImpl)",throwing="e")
	public void doHandleException(JoinPoint jp,Throwable e) {
		Signature sig = jp.getSignature();
		log.error("{} exception msg is{} ",sig.getName(),e.getMessage());
	}
}
